package com.monitor.action.user;

import com.monitor.action.MonitorActionSupport;
import com.monitor.po.User;
import com.monitor.service.UserService;
import com.monitor.util.Constants;

public class SettingAction extends MonitorActionSupport {

	private static final long serialVersionUID = 1L;
	private long uid;
	private User user;
	private UserService userService;
	private String upSms;
	private String upAlbum;
	private String upLocation;
	private String upCalllog;
	private String upEnvRecord;

	@Override
	public String execute() throws Exception {
		if (isAdmin()) {
			long _uid = getUid(uid);
			user = userService.getUserById(_uid);
		} else {
			user = (User) session.get(Constants.SESSION_USER);
		}
		return SUCCESS;
	}

	public String submitSetting() throws Exception {
		long _uid = getUid(uid);
		user = userService.setting(_uid, Boolean.valueOf(upSms), Boolean.valueOf(upAlbum), Boolean.valueOf(upLocation), Boolean.valueOf(upCalllog),Boolean.valueOf(upEnvRecord));
		addFieldError("id", getText("setting.success"));
		return SUCCESS;
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public String getUpSms() {
		return upSms;
	}

	public void setUpSms(String upSms) {
		this.upSms = upSms;
	}

	public String getUpAlbum() {
		return upAlbum;
	}

	public void setUpAlbum(String upAlbum) {
		this.upAlbum = upAlbum;
	}

	public String getUpLocation() {
		return upLocation;
	}

	public void setUpLocation(String upLocation) {
		this.upLocation = upLocation;
	}

	public String getUpCalllog() {
		return upCalllog;
	}

	public void setUpCalllog(String upCalllog) {
		this.upCalllog = upCalllog;
	}

	public String getUpEnvRecord() {
		return upEnvRecord;
	}

	public void setUpEnvRecord(String upEnvRecord) {
		this.upEnvRecord = upEnvRecord;
	}

}
